//
//  ScreenViewController.m
//  navigation
//
//  Created by Bc_Ltf on 15/1/29.
//  Copyright (c) 2015年 Bc_Ltf. All rights reserved.
//

#import "ScreenViewController.h"

@interface ScreenViewController ()<UIScrollViewDelegate>

@end

@implementation ScreenViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets=NO;
    
    self.scroller.frame=CGRectMake(0, 0, WEIGHT, HEIGHT-150);
    
    // 重绘scrollview的 范围  三倍屏幕宽度  一倍自己宽度
    self.scroller.contentSize=CGSizeMake(WEIGHT*3, HEIGHT-150);

    // 绘制三个图片
    self.page1=[[UIImageView alloc]initWithFrame:CGRectMake(0,0, WEIGHT, HEIGHT-150)];
    self.page1.image=[UIImage imageNamed:@"保罗克利-肖像.png"];
    
    self.page2=[[UIImageView alloc]initWithFrame:CGRectMake(WEIGHT, 0, WEIGHT, HEIGHT-150)];
    self.page2.image=[UIImage imageNamed:@"罗丹-思想者"];
    
    self.page3=[[UIImageView alloc]initWithFrame:CGRectMake(WEIGHT*2.0, 0, WEIGHT, HEIGHT-150)];
    self.page3.image=[UIImage imageNamed:@"达芬奇-蒙娜丽莎"];
    
    self.scroller.delegate=self;
    
    [self.scroller addSubview:self.page1];
    [self.scroller addSubview:self.page2];
    [self.scroller addSubview:self.page3];
    
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGPoint offset=scrollView.contentOffset;
    self.pager.currentPage=offset.x/WEIGHT;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)changeValue:(id)sender {
    [UIView animateWithDuration:0.3f animations:^{
        NSInteger whichPage=self.pager.currentPage;
        self.scroller.contentOffset=CGPointMake(WEIGHT*whichPage, 0.0f);
    }];
}
@end



























